package com.morn.fanfou.util;

import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.params.ConnRoutePNames;

import android.content.Context;
import android.net.Proxy;
import android.net.wifi.WifiManager;

public class HttpProxy {
	public static void setProxy(Context context, HttpClient mHttpClient) {
		WifiManager wifiManager = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);
		if (!wifiManager.isWifiEnabled()) {
			String host = Proxy.getDefaultHost();
			int port = Proxy.getDefaultPort();
			if (host != null && !"".equals(host)) {
				HttpHost httpHost = new HttpHost(host, port);
				mHttpClient.getParams().setParameter(
						ConnRoutePNames.DEFAULT_PROXY, httpHost);
			}
		} else {
			mHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
					null);
		}
	}
}
